The invention relates to a method and an apparatus for liquefying a feed gas or cooling a feed gas at supercritical pressure, for example a gas rich in carbon dioxide, comprising for example at least 60 mol % carbon dioxide, or even at least 80 mol % carbon dioxide.